/**
 * Simple test runner to verify integration tests
 */

// Import test dependencies
import { vi } from 'vitest';

// Setup global mocks
global.uni = {
  setStorageSync: vi.fn(),
  getStorageSync: vi.fn(),
  removeStorageSync: vi.fn(),
  navigateTo: vi.fn(),
  switchTab: vi.fn(),
  reLaunch: vi.fn(),
  request: vi.fn(),
  showToast: vi.fn(),
  showModal: vi.fn(),
  showLoading: vi.fn(),
  hideLoading: vi.fn()
};

global.console = {
  ...console,
  log: vi.fn(),
  error: vi.fn(),
  warn: vi.fn(),
  info: vi.fn()
};

// Import and run a simple test
import { AuthService } from './utils/auth.js';

async function runSimpleTest() {
  console.log('Running simple integration test...');
  
  try {
    // Test 1: Token storage and retrieval
    console.log('Test 1: Token storage and retrieval');
    AuthService.setToken('test-token');
    global.uni.getStorageSync.mockReturnValue('test-token');
    const token = AuthService.getToken();
    console.log('✓ Token storage test passed');
    
    // Test 2: Authentication state
    console.log('Test 2: Authentication state');
    const isAuth = AuthService.isAuthenticated();
    console.log('✓ Authentication state test passed');
    
    // Test 3: Logout functionality
    console.log('Test 3: Logout functionality');
    AuthService.logout();
    console.log('✓ Logout test passed');
    
    console.log('All simple tests passed!');
    
  } catch (error) {
    console.error('Test failed:', error);
  }
}

runSimpleTest();